﻿/*
 * IServiceInstanceFactory
 * 
 * Used to create service instance
 * ATTENTION: if you need custom service instance factory, you can implement this interface, 
 * and also, please make a public constructor which contains a service type parameter
 * 
 * Author: snowdreamist
 * Date: 2011/12/7
 * 
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BitTorrentSharp.KRPC.Handler
{
    public interface IServiceInstanceFactory
    {
        object CreateServiceInstance();
    }

    public class DefaultServiceInstanceFactory : IServiceInstanceFactory
    {
        public DefaultServiceInstanceFactory(Type serviceType)
        {
            if (serviceType == null)
                throw new ArgumentNullException("serviceType");
            this._serviceType = serviceType;
        }

        public object CreateServiceInstance()
        {
            return Activator.CreateInstance(this._serviceType);
        }

        #region private

        private Type _serviceType;

        #endregion
    }
}
